package Adapters;

import java.util.ArrayList;
import java.util.List;


import com.example.mainproject.R;

import classes.Ticket;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class TicketAdapter extends ArrayAdapter<Ticket>{

	Context context;
	int ResID;
	ArrayList<Ticket> tickets;
	TextView tvTicket, tvSeriaNo, tvAddress;
	
	public TicketAdapter(Context context, int textViewResourceId,
			List<Ticket> objects) {
		super(context, textViewResourceId, objects);
		this.context = context;
		this.ResID = textViewResourceId;
		this.tickets = (ArrayList<Ticket>) objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater = ((Activity) context).getLayoutInflater();
		convertView = inflater.inflate(ResID, null);
		tvTicket = (TextView) convertView.findViewById(R.id.tr_tv_TicketNo);
		tvSeriaNo = (TextView) convertView.findViewById(R.id.tr_tv_SerialNo);
		tvAddress = (TextView) convertView.findViewById(R.id.tr_tv_Address);
		Ticket s = tickets.get(position);
		
		tvTicket.setText(s.getTicketCode()+"");
		tvSeriaNo.setText(s.getSerialNo()+"");
		tvAddress.setText(s.getProvince());
		return convertView;
	}

}
